<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理人员增加</title>
<base href="<%=basePath%>">
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>res/lsj/js/layui/css/layui.css" media="all">
<style type="text/css">
	body{
		margin:20px 0px;
	}
</style>
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>增加地区</legend>
	</fieldset>

	<form class="layui-form" action="<%=basePath%>fodArea/add" method="post">
		<div class="layui-form-item">
			
			<div class="layui-inline">
				<label class="layui-form-label">地区名称</label>
				<div class="layui-input-inline">
					<input type="text" name="areaName" id="areaName" required
						lay-verify="required" placeholder="地区名称" maxlength="9"
						autocomplete="off" class="layui-input">
				</div>
			</div>
			
		</div>
 	
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">上级地区</label>
				<div class="layui-input-inline">
					<input type="text" id="fodArea"
						maxlength="11" placeholder="上级地区"
						autocomplete="off" class="layui-input" disabled="">
					<input type='hidden' id="areaPid" name="areaPid">
					<ul id="fodAreaTree"></ul>
				</div>
			</div>
		</div>

		

		<div class="layui-form-item">
			<div class="layui-input-block">
				<input type="submit" class="layui-btn" lay-submit=""
					lay-filter="Add" value="立即增加">
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<script src="<%=basePath%>res/lsj/js/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript">
	
	
	
	
		layui.use(['form','tree'], function(){
			  var form = layui.form
			  ,layer = layui.layer
			  ,$ = layui.$;
			  
			  form.on('submit(Add)',function(){
				  parent.location.reload(); // 父页面刷新
			  });
			  
			  var url="<%=basePath%>fodArea/getTree";
			  var data= null;
			  $.post(url,data,function(msg){
				  layui.tree({
					  elem: '#fodAreaTree' //传入元素选择器
					  ,nodes: msg
					  ,click: function(node){
						 $("#fodArea").val(node.name);
						 
						 $("#areaPid").val(node.id);
					  }  
					});
			  });
			  
			});
	</script>
</body>
</html>